home *** CD-ROM | disk | FTP | other *** search
/ Aminet 44 / Aminet 44 (2001)(GTI - Schatztruhe)[!][Aug 2001].iso / Aminet / comm / misc / DigiCamGUI.lha / DigiCam_Triton.rexx next >
OS/2 REXX Batch file  |  2001-06-28  |  14KB  |  389 lines

  1. /*
  2. ** GUI Control Panel for DigiCam 1.0
  3. ** $VER: DigiCam_Triton.rexx 1.0 (28.06.2001)
  4. **
  5. ** By Roger Clark (kaedric@cd-memories.com)
  6. ** June 28, 2001
  7. **
  8. ** This script requires the rexxreqtools.library which can be found on Aminet.
  9. **                      util/rexx/RexxReqTools.lha
  10. **
  11. ** This script requires the tritonrexx.library which can be found on Aminet.
  12. **                      util/rexx/TritonRexx376.lha
  13. **
  14. ** This script requires the triton.library which can be found on Aminet.
  15. **                      dev/gui/tri20b1usr.lha
  16. **
  17. */
  18.  
  19. /*****************************************************************/
  20. /*** Set the following variables for your system configuration ***/
  21. /*****************************************************************/
  22.  
  23. PubScreen    = 'Workbench'
  24. ProgramPath  = 'Photos:DigiCam/DigiCam'
  25. SerialDevice = 'serial.device'
  26. SerialPort   = 0
  27. BaudRate     = 115200
  28. PhotoPath    = "Photos:Photo"
  29.  
  30. /*****************************************************************/
  31. /*** Set the following variables for your camera configuration ***/
  32. /*****************************************************************/
  33.  
  34. Resolution.1 = "640x480"
  35. Resolution.2 = "1280x960"
  36. Resolution.3 = "1280x960"
  37. Resolution.4 = "1600x1200"
  38.  
  39. Color.1 = "Color"
  40. Color.2 = "B&W"
  41.  
  42. Flash.0 = "Auto"
  43. Flash.1 = "Forced"
  44. Flash.2 = "Off"
  45.  
  46. /*****************************************************************/
  47.  
  48. Options Results
  49.  
  50. Signal On Break_C
  51. Signal On failure
  52. Signal On halt
  53. Signal On ioerr
  54. Signal On syntax
  55.  
  56. If ~Show('L','tritonrexx.library') Then Do
  57.    If ~addlib('tritonrexx.library',10,-30,0) Then Do
  58.       Say 'Could not access the tritonrexx.library!'
  59.       Exit 10
  60.    End
  61. End
  62.  
  63. If ~Show('L','rexxreqtools.library') Then Do
  64.    If ~addlib('rexxreqtools.library',10,-30,0) Then Do
  65.       Say 'Could not access the rexxreqtools.library!'
  66.       Exit 10
  67.    End
  68. End
  69.  
  70. DigiCam = ProgramPath" "SerialDevice" "SerialPort" "BaudRate" "
  71.  
  72. HelpBool = 0
  73.  
  74. CameraInfo. = " "
  75. CameraInfo.0 = 5
  76. PhotoInfo. = " "
  77. PhotoInfo.0 = 0
  78.  
  79. Status = "Status: Waiting For Input                      "
  80.  
  81. apptags =      'TRCA_Name     DigiCam',
  82.                'TRCA_LongName "DigiCam Control Panel"',
  83.                'TRCA_Info     "DigiCam Control Panel"',
  84.                'TRCA_Version  "1.0"',
  85.                'TRCA_Release  "1"',
  86.                'TRCA_Date     "27.06.01"',
  87.                'TAG_END'
  88.  
  89. windowtags =    WindowID(1),
  90.                 WindowTitle('DigiCam Control Panel'),
  91.                 WindowPosition('TRWP_CENTERDISPLAY'),
  92.                 WindowFlags('TRWF_NOSIZEGADGET'),
  93.                 PubScreenName(PubScreen),
  94.                 QuickHelpOn(HelpBool),
  95.                   BeginMenu('Project'),
  96.                     MenuItem('I_Information',1),
  97.                     MenuItem('V_View Thumbnail',2),
  98.                     MenuItem('D_Download Photo',3),
  99.                     MenuItem('E_Erase Photo',4),
  100.                     'ItemBarLabel',
  101.                     MenuItem('H_Quick Help',6) 'TRMN_Flags TRMF_CHECKIT',
  102.                     'ItemBarLabel',
  103.                     MenuItem('?_About',7),
  104.                     MenuItem('Q_Quit',8),
  105.                   'HorizGroupE',
  106.                     'Space',
  107.                     'VertGroupA',
  108.                       'Space',
  109.                       'HorizGroupEA',
  110.                         'Space',
  111.                         Button('Information',1) 'TRDO_QuickHelpString "Display information from camera"',
  112.                         Button('View Thumbnail',2) 'TRDO_QuickHelpString "View selected thumbnail image from camera"',
  113.                         Button('Download Photo',3) 'TRDO_QuickHelpString "Download full sized images from camera"',
  114.                         Button('Erase Photo',4) 'TRDO_QuickHelpString "Erase photos from the camera''s memory"',
  115.                         'Space',
  116.                       'EndGroup',
  117.                       'Space',
  118.                       NamedSeparatorIN("Camera Information",9),
  119.                       'HorizGroup',
  120.                         'Space',
  121.                         ListRO(CameraInfo,10,0) 'TRAT_MINHEIGHT 5',
  122.                         'Space',
  123.                       'EndGroup',
  124.                       NamedSeparatorIN("Camera Directory",11),
  125.                       TextN('  Num   Bytes   Resolution           Date'),
  126.                       ListSS('PhotoInfo',12,0,0) 'TRAT_MINHEIGHT 20',
  127.                       'Space',
  128.                       TextBox(Status,13,0),
  129.                       'Space',
  130.                     'EndGroup',
  131.                     'Space',
  132.                   'EndGroup',
  133.                 'EndProject'
  134.  
  135.  
  136. app = TR_CREATEAPP(apptags)
  137. If app ~= '00000000'x Then Do
  138.   window = TR_OPENPROJECT(app,windowtags)
  139.   If window ~= '00000000'x Then Do
  140.     Done = 0
  141.     Do While Done ~= 1
  142.       Call TR_WAIT(app,'')
  143.       Do While TR_HANDLEMSG(app,'event')
  144.         If event.trm_class = 'TRMS_NEWVALUE' Then Do
  145.           Select
  146.             When event.trm_id = 6 Then Do
  147.               HelpBool = 1 - HelpBool
  148.               Call TR_SETATTRIBUTE(window,0,'TRWI_QuickHelp',HelpBool)
  149.             End
  150.             Otherwise NOP
  151.           End
  152.         End
  153.         If event.trm_class = 'TRMS_ACTION' Then Do
  154.           Select
  155.             When event.trm_id = 1 Then Do
  156.               Call GetInfo
  157.             End
  158.             When event.trm_id = 2 Then Do
  159.               Call ThumbView
  160.             End
  161.             When event.trm_id = 3 Then Do
  162.               Call GetPhoto
  163.             End
  164.             When event.trm_id = 4 Then Do
  165.               Call ErasePhoto
  166.             End
  167.             When event.trm_id = 7 Then Do
  168.               Call rtezrequest("DigiCam_Triton.rexx v1.0"||D2C(10)||"By: Roger Clark (kaedric@cd-memories.com)"||D2C(10)||"Date: June 27, 2001","Thanks","About DigiCam_Triton.rexx","rt_pubscrname="PubScreen)
  169.             End
  170.             When event.trm_id = 8 Then Do
  171.               Done = 1
  172.             End
  173.             Otherwise NOP
  174.           End
  175.         End
  176.         If event.trm_class = 'TRMS_CLOSEWINDOW' Then Do
  177.           Done = 1
  178.         End
  179.       End
  180.     End
  181.     Call TR_CLOSEPROJECT(window)
  182.   End
  183.   Call TR_DELETEAPP(app)
  184. End
  185. Exit
  186.  
  187.  
  188. break_c:
  189. failure:
  190. halt:
  191. ioerr:
  192. syntax:
  193.    Call rtezrequest('Notify the author about this!'||D2C(10)||'+++ Error' rc 'in line' sigl '-' ERRORTEXT(rc),'Oops!','Error!','rt_pubscrname='PubScreen)
  194.    If app ~= '00000000'x THEN
  195.       Call TR_DELETEAPP(app)
  196.    Exit
  197.  
  198. GetInfo:
  199. Call TR_SETATTRIBUTE(window,13,'TRAT_Text',"Status: Reading Camera Information             ")
  200.   windowtags =   WindowID(3),
  201.                  WindowPosition('TRWP_CENTERDISPLAY'),
  202.                  WindowFlags('TRWF_NOSIZEGADGET'),
  203.                  WindowTitle('Progress'),
  204.                    'HorizGroupA',
  205.                      'Space',
  206.                      'VertGroupA',
  207.                        'Space',
  208.                        NamedSeparator('Getting Camera Information'),
  209.                        'Space',
  210.                        'HorizGroupSA',
  211.                          TextN("0%"),
  212.                          'SpaceB',
  213.                          TextN("25%"),
  214.                          'SpaceB',
  215.                          TextN("50%"),
  216.                          'SpaceB',
  217.                          TextN("75%"),
  218.                          'SpaceB',
  219.                          TextN("100%"),
  220.                        'EndGroup',
  221.                        Progress(100,0,7),
  222.                        'Space',
  223.                      'EndGroup',
  224.                      'Space',
  225.                    'EndGroup',
  226.                  'EndProject'
  227.  
  228.   progapp = TR_CREATEAPP('TRCA_Name Progress')
  229.   IF progapp ~= '00000000'x THEN Do
  230.     progwindow = TR_OPENPROJECT(progapp,windowtags)
  231.     IF progwindow ~= '00000000'x THEN DO
  232.       CALL TR_SETATTRIBUTE(progwindow,7,'TRAT_Value',25)
  233.       Address Command DigiCam 'INFO >RAM:DigiCamInfo.txt'
  234.       CALL TR_SETATTRIBUTE(progwindow,7,'TRAT_Value',50)
  235.       Call Open(In,"RAM:DigiCamInfo.txt","R")
  236.         Do Until EOF(In)
  237.           Data = ReadLn(In)
  238.           Select
  239.             When Left(Data,18) = "Manufacturer     :" Then Do
  240.               V.1 = SubWord(Data,3)
  241.             End
  242.             When Left(Data,18) = "Model            :" Then Do
  243.               V.2 = SubWord(Data,3)
  244.             End
  245.             When Left(Data,18) = "Version          :" Then Do
  246.               V.3 = SubWord(Data,3)
  247.             End
  248.             When Left(Data,18) = "Cameratime       :" Then Do
  249.               V.4 = SubWord(Data,3)
  250.             End
  251.             When Left(Data,18) = "Frames Taken     :" Then Do
  252.               V.5 = SubWord(Data,4)
  253.             End
  254.             When Left(Data,18) = "Frames Left      :" Then Do
  255.               V.6 = SubWord(Data,4)
  256.             End
  257.             When Left(Data,18) = "Resolution       :" Then Do
  258.               X = SubWord(Data,3)
  259.               V.7 = Resolution.X
  260.             End
  261.             When Left(Data,18) = "Flash Mode       :" Then Do
  262.               X = SubWord(Data,4)
  263.               V.8 = Flash.X
  264.             End
  265.             When Left(Data,18) = "Color Mode       :" Then Do
  266.               X = SubWord(Data,4)
  267.               V.9 = Color.X
  268.             End
  269.             Otherwise NOP
  270.           End
  271.         End
  272.       Call Close(In)
  273.       Call Delete("RAM:DigiCamInfo.txt")
  274.       CameraInfo.1 = "Camera Model - "V.1" "V.2", "V.3
  275.       CameraInfo.2 = "Camera Time  - "V.4
  276.       CameraInfo.3 = "Photo Status - "V.5" Saved / "V.6" Remaining"
  277.       CameraInfo.4 = "Resolution   - "V.7" ("V.9")"
  278.       CameraInfo.5 = "Flash Mode   - "V.8
  279.       Call TR_SETATTRIBUTE(window,10,'TROB_Listview',CameraInfo)
  280.       CALL TR_SETATTRIBUTE(progwindow,7,'TRAT_Value',75)
  281.  
  282.       Call TR_SETATTRIBUTE(window,13,'TRAT_Text',"Status: Reading Camera Directory               ")
  283.       Address Command DigiCam 'DIR >RAM:DigiCamDir.txt'
  284.       CALL TR_SETATTRIBUTE(progwindow,7,'TRAT_Value',100)
  285.       Call Open(In,"RAM:DigiCamDir.txt","R")
  286.         Do Until EOF(In)
  287.           Data = ReadLn(In)
  288.           If Word(Data,1) = "Still" Then Do
  289.             Blah = ReadLn(In)
  290.             Do Loop = 1 to V.5
  291.               PhotoInfo.Loop = ReadLn(In)
  292.               Res = Word(PhotoInfo.Loop,5)
  293.               PhotoInfo.Loop = Left(PhotoInfo.Loop,13)"   "Resolution.Res"   "Strip(SubWord(PhotoInfo.Loop,7,5),"T",D2C(20))
  294.             End
  295.           End
  296.         End
  297.         PhotoInfo.0 = V.5
  298.       Call Close(In)
  299.       Call Delete("RAM:DigiCamDir.txt")
  300.       Call TR_SETATTRIBUTE(window,12,'TROB_Listview',PhotoInfo)
  301.       CALL TR_CLOSEPROJECT(progwindow)
  302.      CALL TR_DELETEAPP(progapp)
  303.     END
  304.   END
  305.   Call TR_SETATTRIBUTE(window,13,'TRAT_Text',"Status: Waiting For Input                      ")
  306. Return
  307.  
  308. ThumbView:
  309. Call TR_SETATTRIBUTE(window,13,'TRAT_Text',"Status: Downloading Thumbnail Image From Camera")
  310. ThumbNumber = Word(TR_GETATTRIBUTE(window,12,'TRAT_Value')+1,1)
  311. Address Command DigiCam 'GT='ThumbNumber' Ram:Thumb >Nil:'
  312. SelectedThumb = "Ram:Thumb_"Thumbnumber"th.jpg"
  313.  
  314. thumbapp = TR_CREATEAPP('TRCA_Name ThumbView',
  315.                    'TRCA_LongName "DigiCam Thumbnail Viewer"',
  316.                    'TRCA_Info     "Display thumbnail photos from DigiCam"',
  317.                    'TRCA_Version  "1.0"',
  318.                    'TRCA_Release  "1"',
  319.                    'TRCA_Date     "28.06.01"',
  320.                    'TAG_END')
  321.  
  322. IF thumbapp = '00000000'x THEN Do
  323.   Call rtezrequest('Unable to create child process to view thumbnail!','Oops!','Error!','rt_pubscrname='PubScreen)
  324.   Return
  325. End
  326.  
  327. imageflags = 'TRXIF_CENTER'
  328.  
  329. IF ~CREATEIMAGE('Thumbnail',SelectedThumb,'TRXIM_PubScreenName' PubScreen 'TRXIM_Flags' imageflags) THEN Do
  330.   Call rtezrequest('Unable to create image pointers for thumbnail!','Oops!','Error!','rt_pubscrname='PubScreen)
  331.   Return
  332. End
  333.  
  334. thumbwindow = TR_OPENPROJECT(thumbapp,WindowID(2),
  335.                             WindowPosition('TRWP_CENTERDISPLAY'),
  336.                             WindowFlags('TRWF_NOMINTEXTWIDTH|TRWF_NOSIZEGADGET'),
  337.                             WindowTitle("Image"),
  338.                             PubScreenName(PubScreen),
  339.                                'HorizGroupAC',
  340.                                   'Space',
  341.                                   'VertGroupAC',
  342.                                      'Space',
  343.                                      'GroupBox',
  344.                                      'HorizGroupAC',
  345.                                         BoopsiImageD('Thumbnail',IMAGEWIDTH('Thumbnail'),IMAGEHEIGHT('Thumbnail')),
  346.                                      'EndGroup',
  347.                                      'Space',
  348.                                   'EndGroup',
  349.                                   'Space',
  350.                                'EndGroup',
  351.                             'EndProject')
  352.  
  353. IF thumbwindow ~= '00000000'x THEN DO
  354.    ende = 0
  355.    Call TR_SETATTRIBUTE(window,13,'TRAT_Text',"Status: Displaying Thumbnail Image             ")
  356.  
  357.    DO WHILE ~ende
  358.       CALL TR_WAIT(thumbapp,'')
  359.  
  360.       DO WHILE TR_HANDLEMSG(thumbapp,'event')
  361.          IF event.trm_class = 'TRMS_CLOSEWINDOW' THEN
  362.             ende = 1
  363.       END
  364.    END
  365.  
  366.    event.trm_class = ''
  367.    CALL TR_CLOSEPROJECT(thumbwindow)
  368.    CALL TR_DELETEAPP(thumbapp)
  369.    CALL DELETEIMAGE('Thumbnail')
  370.    Call Delete(SelectedThumb)
  371. END
  372. Call TR_SETATTRIBUTE(window,13,'TRAT_Text',"Status: Waiting For Input                      ")
  373. Return
  374.  
  375. GetPhoto:
  376. Call TR_SETATTRIBUTE(window,13,'TRAT_Text',"Status: Downloading Image From Camera          ")
  377. PhotoNumber = Word(TR_GETATTRIBUTE(window,12,'TRAT_Value')+1,1)
  378. Address Command DigiCam 'GF='PhotoNumber' 'PhotoPath' >Nil:'
  379. Call TR_SETATTRIBUTE(window,13,'TRAT_Text',"Status: Waiting For Input                      ")
  380. Return
  381.  
  382. ErasePhoto:
  383. Call TR_SETATTRIBUTE(window,13,'TRAT_Text',"Status: Erasing Image From Camera              ")
  384. PhotoNumber = Word(TR_GETATTRIBUTE(window,12,'TRAT_Value')+1,1)
  385. Address Command DigiCam 'ERF='PhotoNumber' >Nil:'
  386. Call GetInfo
  387. Call TR_SETATTRIBUTE(window,13,'TRAT_Text',"Status: Waiting For Input                      ")
  388. Return
  389.